VB Watch Profiler Guided Tour

The purpose of this guided tour is to show you how to use the VB Watch Profiler for finding out where the slow code of a sample project is, and to determine which are the lines that were never executed.


1. Open the Profiler: menu Start / Programs / VB Watch 2 / VB Watch Profiler.


2. Click the Options button and make sure the Full profiling plan is selected.


3. Now click the Profile Project... button on the left and browse for \Program Files\VB Watch 2\Samples\VB6\Profiler Sample\TestProfiler.vbp.


4. When prompted, click the Select all and go button. After instrumentation, the sample loads: click the Start Test button and once done, close the application.


5. The session is automatically loaded in the profiler. The project's components appear in the tree view in the left pane. Expand all the colored branches.

Modules and procedures are colored from red (slowest) to green (fastest). You can see instantly where the slow code is. Legend:


6. How to detect slow code

In the toolbar, check the Display total time button. Select the Modules tab and make sure that the selected item in the tree view is the root node: TestProfiler.exe 1.

You can see that the module in which the most time is spent is modTestProfiler. Click on its name in the grid view. An hyperlink takes you instantly to its procedures view. You can see that the slowest procedure is InverseFileByLine2.

(This figure is not exactly what you should see)

Again, click it. You're taken to the line view, which clearly shows where the bottleneck is: in the "BuildString = ..." line.

Click this line (under the Line column exactly) to get to the source code view. Note: you may also double-click a procedure or a module to jump to the source code view).

Finally, it appears that the string concatenation "BuildString = BuildString & ..." is really slow with large strings. See in InverseFileByLine3 how you can make it much faster by using the Mid$ statement.


7. How to detect untested code

The idea is still the same except that you must check the "Display coverage values" button in the toolbar.

You'll find out that the only untested line resides in the InverseFileByLine3 procedure.

The line in red was never executed. The left margin displays the number of time each line was executed.


8. Additional notes


What do you want to know more about?

VB Watch Profiler Reference

Topic link

Step by step: How to profile your project

Topic link

Step by step: How to profile an activeX dll/ocx/exe

Topic link

Step by step: How to profile an IIS project

Topic link

Step by step: How to profile the execution of your project on another machine